<?php
require_once("conf/db_connection.php");

if($_SESSION['type_nn']=='trucker')
{
$filter_date = $_GET['filter_date'];
if($filter_date=="" || $filter_date==null)
{
	$query_queue="SELECT * FROM trip_detail WHERE (status='for confirmation') AND trucker_id = '".$_SESSION['trucker_id_nn']."' AND status = 'for confirmation' AND is_cancelled='0'";
}
else
{
	$query_queue="SELECT * FROM trip_detail WHERE (status='for confirmation') AND trucker_id = '".$_SESSION['trucker_id_nn']."' AND status = 'for confirmation' AND is_cancelled='0' AND receive_date_time LIKE '".$filter_date."%'";
}
}

if($_SESSION['type_nn']=='agent')
{
$filter_date = $_GET['filter_date'];
if($filter_date=="" || $filter_date==null)
{
	$query_queue="SELECT * FROM trip_detail WHERE (status='queue' OR status='for confirmation') AND is_cancelled='0'";
}
else
{
	$query_queue="SELECT * FROM trip_detail WHERE (status='queue' OR status='for confirmation') AND is_cancelled='0' AND receive_date_time LIKE '".$filter_date."%'";
}
}

$result_queue=mysql_query($query_queue);
?>
<html>
<head>
<script type="text/javascript" src="lib/js/main.js"></script>
<script type="text/javascript" src="lib/js/jquery-1.7.1.js"></script>
<link rel="stylesheet" href="lib/js/jqueryui/css/blitzer/jquery-ui-1.8.17.custom.css">
<!--<link rel="stylesheet" href="lib/js/jqueryui/css/ui-lightness/jquery-ui-1.8.17.custom.css">-->
<script type="text/javascript" src="lib/js/jqueryui/js/jquery-ui-1.8.17.custom.min.js"></script>
<style type = "text/css">
#hor-minimalist-b {
	background-color: #FFFFFF;
    border-collapse: collapse;
    font-family: Georgia;
    font-size: 12px;
    margin: 10px;
    text-align: left;
    width: 900px;
}
#hor-minimalist-b th {
    border-bottom: 2px solid #5F0C0C ;
    color: #5F0C0C;
    font-size: 12px;
    font-weight: bold;
    padding: 10px 8px;
}
#hor-minimalist-b td {
    border-bottom: 1px solid #888888;
    color: #000000;
    padding: 6px 8px;
}
#hor-minimalist-b tbody tr:hover td {
    //color: #0000CC;
	background-color:#BCC5C6;
}
<style type='text/css'>
/* css for timepicker */
.ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
.ui-timepicker-div dl { text-align: left; }
.ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
.ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
.ui-timepicker-div td { font-size: 90%; }
.ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
</style>
</style>
<script>
function popConfirmAssign(id)
{
	xmlhttp_confirm=GetXmlHttpObject();
	if (xmlhttp_confirm==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  }
	var url="ajax_pop_confirm.php";
	url=url+"?id="+id;
	xmlhttp_confirm.onreadystatechange=function (){
	  if (xmlhttp_confirm.readyState==4)
	  {
		parent.disableDiv();
		parent.document.getElementById("pop_div").innerHTML = xmlhttp_confirm.responseText;
		parent.showPopDiv();
	  }
	}
	xmlhttp_confirm.open("GET",url,true);
	xmlhttp_confirm.send(null);	
}

$(document).ready(function (){


		$( "#datepicker" ).datepicker();
		$( "#datepicker" ).datepicker( "option", "dateFormat", 'yy-mm-dd' );
		
		if($("#hfDate").val())
		{
		//$( "#datepicker" ).datepicker( "option", "defaultDate", $("#hfDate").val() );
		$( "#datepicker" ).val($("#hfDate").val());
		}

});


function changeDate(passed_date){
document.location.href = "trucker_queue_list.php?filter_date="+passed_date;
}
function refreshList()
{
	var hfdate = document.getElementById('hfDate').value;
	var ran = Math.floor(Math.random()*11);
	document.location.href = 'trucker_queue_list.php?filter_date='+hfdate+"&ran="+ran;
}
</script>
</head>
<body onLoad='setTimeout("refreshList()",15000);'>
<table border='1' width='900' style='background-color:white;margin-left:auto;margin-right:auto;background-color:#5F0C0C;color:white;font-family:Georgia;font-size:12px'>
<th>QUEUE LIST</th>
</table>
<br />
<div style='position:relative;left:55px;width:900px'><span style='font-family:Georgia;font-size:12px;color:white;font-weight:bold'>Date:&nbsp;</span><input type='text' id='datepicker' name='datepicker' onChange=changeDate(this.value);></div>
<input type='hidden' id='hfDate' name='hfDate' value='<?php echo $filter_date?>' />
<table id='hor-minimalist-b' border='0' width='900' style='margin-left:auto;margin-right:auto'>
<thead>
<tr>
	<th>Status</th>
	<th>Booking Number</th>
	<th>Equipment Size</th>
	<th>Equipment Type</th>
	<th>Positioning Date</th>
	<th>Positioning Time</th>
	<th>Date/Time Received </th>
	<th>Tools </th>
</tr>
</thead>
<?php
while($row_queue = mysql_fetch_array($result_queue))
{
?>
<tbody>
<tr>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo strtoupper($row_queue["status"]) ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["booking_number"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["equipment_size"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["equipment_type"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["positioning_date"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["positioning_time"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px">&nbsp;<?php echo $row_queue["receive_date_time"] ?>&nbsp;</td>
	<td style="text-align:left; font-family:Georgia; font-size:12px"><img onClick='popConfirmAssign(<?php echo $row_queue["id"]?>)'; src='image/confirm.png' style='cursor:pointer' title='Confirm Trip Assignment' /></td>
</tr>
</tbody>
<?php
}
?>
</table>		
</body>
</html>

